package org.example.stream;

import java.util.stream.Stream;

public class Stream05 {
    public static void main(String[] args) {
        System.out.println(Stream.of(1, 2, 3, 4, 5, 6, 7)
                .filter(i -> (i & 1) == 0)
                .findFirst().orElse(-1));
        System.out.println("--------");
        Stream.of(1, 2, 3, 4, 5, 6, 7)
                .filter(i -> (i & 1) == 0)
                .findFirst().ifPresent(System.out::println);
        System.out.println("--------");
        Stream.of(1, 2, 3, 4, 5, 6, 7)
                .filter(i -> (i & 1) == 0)
                .findAny().ifPresent(System.out::println);
        System.out.println("--------");
        System.out.println(Stream.of(1, 2, 3, 4, 5, 6, 7)
                .anyMatch(i -> (i & 1) == 0));
        System.out.println("--------");
        System.out.println(Stream.of(1, 2, 3, 4, 5, 6, 7)
                .allMatch(i -> (i & 1) == 0));
        System.out.println("--------");
        System.out.println(Stream.of(1, 2, 3, 4, 5, 6, 7)
                .noneMatch(i -> (i & 1) == 0));
    }
}
